package com.shadow.bus.login;

import com.alibaba.fastjson.TypeReference;
import com.shadow.bus.config.ItemFiled;
import com.shadow.bus.config.ItemType;
import com.shadow.bus.entity.LoginEntity;
import com.tepth.shadow.ui.recycler.DataConverter;
import com.tepth.shadow.ui.recycler.MultipleItemEntity;
import com.tepth.shadow.ui.recycler.ObjConverter;

import java.util.ArrayList;

/**
 * @author zhangyu
 * @date 2018/7/3
 */

public class LoginDataConverter extends DataConverter {
    @Override
    public ArrayList<MultipleItemEntity> convert() {
        try {
            LoginEntity loginEntity = new ObjConverter<LoginEntity>().
                    convert(getJsonData(), new TypeReference<LoginEntity>() {
                    });
            final MultipleItemEntity multipleItemEntity = MultipleItemEntity
                    .builder()
                    .setItemType(ItemType.TYPE_LOGIN)
                    .setField(ItemFiled.ITEM_OBJ, loginEntity)
                    .build();
            mEntities.add(multipleItemEntity);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mEntities;
    }
}
